<template>
  <div class="PageContent">

    <el-button type="success" icon="el-icon-plus" @click="FIStartDetectFace_Curr()">开启人脸检测 </el-button>
    <el-button type="success" icon="el-icon-plus" @click="FIReadCard_Curr()">读身份证 </el-button>
    <el-button type="success" icon="el-icon-plus" @click="FIStartIdentifyFace_Curr()">开启人脸比对 </el-button>
    <el-button type="success" icon="el-icon-plus" @click="FIStopDetectFace_Curr()">停止人脸检测</el-button>


    <table align="center" border="1" cellpadding="1" cellspacing="1">
      <tr>
        <td>
          <div align="center">操作提示</div>
        </td>
        <td height="80">
          <div id="idTips" align="center"></div>
        </td>
      </tr>
      <tr>
        <td>
          <div align="center">操作状态</div>
        </td>
        <td>
          <table align="center" width="1200" height="80" border="0" cellpadding="0"	cellspacing="0">
            <tr>
              <td height="38" width = "200"><div align="left" class="form_text">初始化状态：</div></td>
              <td width = "200"><input type="text" name="result" class="form_input" id="idInitStatus" ></td>
              <td height="38" width = "200"><div align="left" class="form_text">打开视频状态：</div></td>
              <td width = "200"><input type="text" name="resultDesc" class="form_input" id="idOpenVideoStatus"></td>
              <td height="38" width = "200"><div align="left" class="form_text">开启人脸检测状态：</div></td>
              <td width = "200"><input type="text" name="Name" class="form_input" id="idStartDetectStatus"></td>

            </tr>
            <tr>
              <td height="38"><div align="left" class="form_text">开启人脸比对状态：</div></td>
              <td><input type="text" name="Sex" class="form_input" id="idStartIdentifyStatus"></td>
              <td height="38"><div align="left" class="form_text">读卡状态：</div></td>
              <td><input type="text" name="Sex" class="form_input" id="idReadCardStatus"></td>
              <td height="38"><div align="left" class="form_text">停止人脸检测状态：</div></td>
              <td><input type="text" name="Sex" class="form_input" id="idCloseDetectStatus"></td>

            </tr>
            <tr>
              <td height="38"><div align="left" class="form_text">反初始化状态：</div></td>
              <td><input type="text" name="Sex" class="form_input" id="idUnInitStatus"></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <div align="center">人脸比对结果</div>
        </td>
        <td>
          <table align="center" width="1200" height="50" border="0" cellpadding="0"	cellspacing="0">
            <tr>
              <td height="38" width = "200"><div align="left" class="form_text">彩色人脸比对分数：</div></td>
              <td width = "200"><input type="text" name="Sex" class="form_input" id="idColorIdfyScore"></td>
              <td height="38" width = "200"><div align="left" class="form_text">彩色活体比对分数：</div></td>
              <td width = "200"><input type="text" name="Sex" class="form_input" id="idColorLiveScore"></td>
              <td height="38" width = "200"><div align="left" class="form_text">红外活体比对分数：</div></td>
              <td width = "200"><input type="text" name="Sex" class="form_input" id="idGrayLiveScore"></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <div align="center">身份证阅读结果</div>
        </td>
        <td>
          <table align="center" width="1200" height="150" border="0" cellpadding="0"	cellspacing="0">
            <td width="250">
              <image align="right" border ="1" width="102" height="126" src="" id="idIdPhoto"></image>
            </td>
            <td>
              <table align="center"  height="200" border="0" cellpadding="0"	cellspacing="0">
                <tr>
                  <td height="30" width="100"><div align="left" class="form_text">姓名：</div></td>
                  <td><input type="text" name="Sex" class="form_input" id="idName" size="15"></td>
                </tr>
                <tr>
                  <td height="30"><div align="left" class="form_text">身份证号：</div></td>
                  <td><input type="text" name="Sex" class="form_input" id="idIdNum" size="30"></td>
                </tr>
                <tr>
                  <td height="30"><div align="left" class="form_text">地址：</div></td>
                  <td><input type="text" name="Sex" class="form_input" id="idAddress" size="100"></td>
                </tr>
                <tr>
                  <td height="30"><div align="left" class="form_text">有效日期：</div></td>
                  <td><input type="text" name="Sex" class="form_input" id="idUseLife" size="30"></td>
                </tr>
              </table>
            </td>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <div align="center">基本操作</div>
        </td>
        <td align="center" height = "70">
          <!--<input id=button1 type=button value=初始化 name=button15  onclick="FIInit();" style="Z-INDEX: 0">
                <input id=button2 type=button value=打开视频 name=button15  onclick="FIOpenVideo();" style="Z-INDEX: 0">-->
          <input id=button3 type=button value=开启人脸检测 name=button15  onclick="FIStartDetectFace();" style="Z-INDEX: 0">
          <input id=button4 type=button value=开启人脸比对 name=button15  onclick="FIStartIdentifyFace_Curr();" style="Z-INDEX: 0">
          <input id=button7 type=button value=读身份证 name=button15  onclick="FIReadCard();" style="Z-INDEX: 0">
          <input id=button5 type=button value=停止人脸检测 name=button15  onclick="FIStopDetectFace();" style="Z-INDEX: 0">
          <!--<input id=button6 type=button value=反初始化 name=button15  onclick="FIUnInit();" style="Z-INDEX: 0">-->
        </td>
      </tr>
      <tr>
        <td>
          <div align="center">视频显示</div>
        </td>
        <td align="center">
          <object id="FLFICtrl" name="FLFICtrl" classid="clsid:4599E8E2-0E4A-4F0F-B034-7252B66C2F1F" width="1000" height="350"></object>
        </td>
      </tr>
    </table>

    <div class="PageItem" >





  </div>
  </div>
</template>


<script>
   import  fsPerson   from '@/api/FS1000A3TDPersonCard'
    export default {
        name: "PhotoRecord",
      data() {return {
        bFIInit:false,
        fThreshold:0.7,//验证门限
        strTipsType:"StartReadCard",
        timerFlag1:false,//提示牌定时器标志
        timerFlag2:false,//身份证阅读定时器标志
        bFIInit:false,//人脸模块初始化标志
        bRCInit:false,//身份证模块初始化标志
        bIsGrayVideoInit:false,//控制活体检测模式
        bTipFlash:true,//控制提示是否闪烁
        FLFICtrl:{}//active对象

       }
      },
      methods: {
        // 单元格的 style 的回调方法
        FIStartDetectFace_Curr() {
          fsPerson.FIStartDetectFace();
         },//读身份证
          FIReadCard_Curr(){
            fsPerson.FIReadCard_C1();
          },
        //停止人脸检测
        FIStopDetectFace_Curr(){
          fsPerson.FIStopDetectFace_Photo();
        },//开启人脸对比
        FIStartIdentifyFace_Curr(){
          fsPerson.FIStartIdentifyFace();
        },//新增script脚本
        appScript:function () {
          var ring = document.createElement("script");
          ring.setAttribute("for","FLFICtrl");
          ring.event="OnIdentifyFace()";
          ring.appendChild(document.createTextNode("phoneListener.ringUp()"))
          document.body.appendChild(ring)
        },
        check(){
          var fFaceScore = FLFICtrl.FaceScore.toFixed(6);
          var fColorLiveScore = FLFICtrl.ColorLiveScore.toFixed(6);
          var fGrayLiveScore = FLFICtrl.GrayLiveScore.toFixed(6);
          var nVerifyStatus = FLFICtrl.VerifyStatus;
        },
        addEvent(){
          $('body').bind('OnIdentifyFace', function (event) {
            var fFaceScore = FLFICtrl.FaceScore.toFixed(6);
            var fColorLiveScore = FLFICtrl.ColorLiveScore.toFixed(6);
            var fGrayLiveScore = FLFICtrl.GrayLiveScore.toFixed(6);
            var nVerifyStatus = FLFICtrl.VerifyStatus;

            var FaceScoreValue;
            if(fFaceScore == -10001)
            {
              FaceScoreValue = "未加载到照片";
            }else if(fFaceScore == -10002)
            {
              FaceScoreValue = "未检测到照片人脸";
            }else if(fFaceScore == -10003)
            {
              FaceScoreValue = "未提取到照片人脸特征";
            }else if(fFaceScore == -20001)
            {
              FaceScoreValue = "未检测到视频人脸";
            }else if(fFaceScore == -20002)
            {
              FaceScoreValue = "未提取到视频人脸特征";
            }else{
              FaceScoreValue = fFaceScore;
            }

            var ColorLiveScoreValue;
            if(fColorLiveScore == -10001)
            {
              ColorLiveScoreValue = "未加载到照片";
            }else if(fColorLiveScore == -10002)
            {
              ColorLiveScoreValue = "未检测到照片人脸";
            }else if(fColorLiveScore == -10003)
            {
              ColorLiveScoreValue = "未提取到照片人脸特征";
            }else if(fColorLiveScore == -20001)
            {
              ColorLiveScoreValue = "未检测到视频人脸";
            }else if(fColorLiveScore == -20002)
            {
              ColorLiveScoreValue = "未提取到视频人脸特征";
            }else if(fColorLiveScore == -1)
            {
              ColorLiveScoreValue = "未开启";
            }else{
              ColorLiveScoreValue = fColorLiveScore;
            }

            var GrayLiveScoreValue;
            if(fGrayLiveScore == -10001)
            {
              GrayLiveScoreValue = "未加载到照片";
            }else if(fGrayLiveScore == -10002)
            {
              GrayLiveScoreValue = "未检测到照片人脸";
            }else if(fGrayLiveScore == -10003)
            {
              GrayLiveScoreValue = "未提取到照片人脸特征";
            }else if(fGrayLiveScore == -20001)
            {
              GrayLiveScoreValue = "未检测到视频人脸";
            }else if(fGrayLiveScore == -20002)
            {
              GrayLiveScoreValue = "未提取到视频人脸特征";
            }else if(fGrayLiveScore == -1)
            {
              GrayLiveScoreValue = "未开启";
            }else{
              GrayLiveScoreValue = fGrayLiveScore;
            }

            document.getElementById("idColorIdfyScore").value = FaceScoreValue;
            document.getElementById("idColorLiveScore").value = ColorLiveScoreValue;
            document.getElementById("idGrayLiveScore").value = GrayLiveScoreValue;

            if(nVerifyStatus == 0)//在验证中
            {
              if(fFaceScore == -20001)
              {
                strTipsType = "DetectingVideoFace";//在验证中视频未发现人脸
              }else if(fFaceScore == -20002)
              {
                strTipsType = "GettingVideoFaceFeature";//在验证中视频提取人脸特征失败
              }else{
                strTipsType = "IndentifyingFail";//在验证中分数不够或者活体未通过
              }
            }else if(nVerifyStatus == 1)//验证通过
            {
              strTipsType = "FaceIdentifySuccess";
              setTimeout(function(){
                strTipsType = "StartReadCard";
                ClearInfo();
                clearInterval(timerFlag2);
                timerFlag2 = setInterval("AutoReadCard()",500);
              },5000);
            }else if(nVerifyStatus == -1)//验证失败
            {
              if(fFaceScore == -10001)
              {
                strTipsType = "LoadPhotoFail";//加载证件照片失败验证失败
              }else if(fFaceScore == -10002)
              {
                strTipsType = "GetPhotoFaceFail";//验证失败照片没找到人脸
              }else if(fFaceScore == -10003)
              {
                strTipsType = "GetPhotoFaceFeatureFail";//验证失败照片人脸特征提取失败
              }else if(fFaceScore == -20001)
              {
                strTipsType = "GetVideoFaceFail";//验证失败视频中没找到人脸
              }else if(fFaceScore == -20002)
              {
                strTipsType = "GettVideoFaceFeatureFail";//验证失败视频提取人脸特征失败
              }else{
                strTipsType = "IndentifyFail";//验证失败分数不够或者活体未通过
              }
              //复位
              setTimeout(function(){
                strTipsType = "StartReadCard";
                ClearInfo();
                clearInterval(timerFlag2);
                timerFlag2 = setInterval("AutoReadCard()",500);
              },5000);
            }
            console.log(typeof event);        // object
          });

        }

       },mounted() {
          //


        //
           //页面加载完成后，才能开始打开视频
           // this.onint();
       /* fsPerson.FIInit();
        fsPerson.FIOpenVideo();*/
          setTimeout(function(){
            fsPerson.FIOpenVideo();
          },100);
         //FIOpenVideo();
          setTimeout(function(){
            fsPerson.FIInit();
          },10);
         //需要等视频完全打开后才能检测人脸
        /*  setTimeout("fsPerson.FIStartDetectFace()",2000);*/
        setTimeout(function(){
          fsPerson.FIStartDetectFace()
        },2000);


        //this.appScript();
        //当前页面调用ocx对就脚本
       // window.phoneListener = this;
      }
    }
</script>
<style scoped>

</style>
